import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ConfigModule } from '@nestjs/config';
import { BudgetModule } from './budget/budget.module';
import { getConfig } from './utils';
import { AuthModule } from './auth/auth.module';
import { APP_GUARD } from '@nestjs/core';
import { JwtAuthGuard } from './auth/jwt-auth.guard';
import { UserInfoModule } from './user-info/user-info.module';
import { MenuModule } from './menu/menu.module';
import { RoleModule } from './role/role.module';
import { PurchaseModule } from './purchase/purchase.module';
import { TypeModule } from './type/type.module';
import { TaskModule } from './task/task.module';
import { WarehouseModule } from './warehouse/warehouse.module';
import { InStoreModule } from './in-store/in-store.module';
import { ReceiveModule } from './receive/receive.module';
import { ScrapModule } from './scrap/scrap.module';
import { FixModule } from './fix/fix.module';
import { AllocateModule } from './allocate/allocate.module';
import { OrgModule } from './org/org.module';
import { BorrowModule } from './borrow/borrow.module';
import { EasterModule } from './easter/easter.module';
import { InventoryModule } from './inventory/inventory.module';
import { AssetsModule } from './assets/assets.module';

@Module({
  imports: [
    ConfigModule.forRoot({
      ignoreEnvFile: true,
      isGlobal: true,
      load: [getConfig],
    }),
    // 数据库连接
    TypeOrmModule.forRoot({
      type: 'mysql',
      host: 'localhost',
      port: 3306,
      username: 'root',
      password: '250182',
      database: 'zcglsystem',
      entities: [],
      synchronize: true,
      autoLoadEntities: true,
    }),
    BudgetModule,
    AuthModule,
    UserInfoModule,
    MenuModule,
    RoleModule,
    PurchaseModule,
    TypeModule,
    TaskModule,
    WarehouseModule,
    InStoreModule,
    ReceiveModule,
    ScrapModule,
    FixModule,
    AllocateModule,
    OrgModule,
    BorrowModule,
    EasterModule,
    InventoryModule,
    AssetsModule,
  ],

  controllers: [AppController],
  providers: [
    AppService,
    // 全局权限校验守卫
    {
      provide: APP_GUARD,
      // useClass: AuthGuard('jwt'),
      useClass: JwtAuthGuard,
    },
  ],
})
export class AppModule { }
